﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BIS.Portal.Modules.CMS.Entity;
using System.Data;
using BIS.Utility.DAL;
using System.Data.SqlClient;
using BIS.Utility.DAL.DataMapper;

namespace BIS.Portal.Modules.CMS.DAL
{
    class AdminCmsArticleDisplaySpecialDAL
    {

        public static IList<AdminCmsArticleDisplaySpecialEntity> SearchArticleDisplaySpecial(int displayTypeId, int languageInUseId)
        {
            IList<AdminCmsArticleDisplaySpecialEntity> list;

            SqlParameter[] param = new SqlParameter[]
                                       {                                                                                      
                                           new SqlParameter("@display_type_id", displayTypeId),                                           
                                           new SqlParameter("@language_in_use_id",languageInUseId),                                                                                       
                                       };

            using (IDataReader reader = SqlHelper.ExecuteReader(DALConnection.ConnectionString,
                                        CommandType.StoredProcedure,
                                        "BIS_sCMS_ARTICLE_SearchArticleDisplaySpecial",
                                        param))
            {
                list = EntityMapper.FillCollection<AdminCmsArticleDisplaySpecialEntity>(reader);
            }

            return list;
        }

        public static int UpdateSpecialPriority(int articleId, int displayTypeId, int specialPriority)
        {
            SqlParameter[] param = new SqlParameter[]
                                       {                                                              
                                           new SqlParameter("@article_id",articleId),
                                           new SqlParameter("@display_type_id",displayTypeId),
                                           new SqlParameter("@special_priority", specialPriority)
                                           
                                       };
            

            return SqlHelper.ExecuteNonQuery(DALConnection.ConnectionString,
                                             CommandType.StoredProcedure,
                                             "BIS_sCMS_ARTICLE_SPECIAL_DISPLAY_UpdateSpecialPriority",
                                             param);
        }
    }
}
